<template>
	<view class="icons bg-color">
		<view class="icon-item" v-for="(item,index) in metadata.menuList" :key="index" @tap="handleClick(item)">
			<image class="icon-img" :src="item.icon" mode=""></image>
			<text class="icon-name">{{ item.title }}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {metadata: Object},
		data() {
			return {
			}
		},
		methods: {
			handleClick(obj) {
				if(obj.type === 1) {
					uni.navigateTo({
						url: obj.url
					})
					return
				}
				if(obj.type === 2) {
					location.href = obj.url
					return
				}
				if(obj.type === 3) {
					uni.switchTab({
						url: obj.url
					})
				}
			}
		}
	}
</script>

<style scoped>
	.icons {
		display: flex;
		flex-wrap: wrap;
		margin: 0 auto;
		width: 96%;
		padding: 20rpx 0;
		margin-top: 20rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
	}

	.icon-item {
		width: 20%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15rpx 0;
	}

	.icon-img {
		width: 60rpx;
		height: 60rpx;
	}

	.icon-name {
		color: gray;
		margin-top: 4rpx;
		font-size: 20rpx;
	}
</style>